package com.jumper.study.front.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jumper.study.common.api.CommonResult;
import com.jumper.study.front.dto.resp.BannerResp;
import com.jumper.study.front.dto.resp.HomeResp;
import com.jumper.study.front.dto.resp.LessonListItemResp;
import com.jumper.study.front.service.BannerService;
import com.jumper.study.front.service.LessonService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;



@RestController("frontHomeController")
@RequestMapping("/api/front")
public class HomeController {

    @Autowired
    private BannerService bannerService;

    @Autowired
    private LessonService lessonService;

    /**
     * 首页接口
     * @return
     */
    @GetMapping("/home")
    public CommonResult<HomeResp> index() {
        List<BannerResp> banners = bannerService.homeList();
        List<LessonListItemResp> lessons = lessonService.recommendList();

        HomeResp resp = new HomeResp();
        resp.setBanners(banners);
        resp.setLessons(lessons);
        resp.setNotice("欢迎使用本学习平台");

        return CommonResult.success(resp);
    }
    
}
